#region

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

using Pob.GameObjects;

#endregion

namespace Pob.ScreenManagement
{
    public class SpielModus1 : Game
    {
        #region Fields

        private readonly GraphicsDeviceManager _graphics;

        #endregion

        #region Constructors and Destructors

        public SpielModus1()
        {
            this._graphics = new GraphicsDeviceManager(this);
            this.Content.RootDirectory = "Content";
        }

        #endregion

        #region Methods

        protected override void Draw(GameTime gameTime)
        {
            this.GraphicsDevice.Clear(Color.Black);

            base.Draw(gameTime);
        }

        protected override void Initialize()
        {
            this.Components.Add(new Ball(this, "Ball", new Vector2(300, 100), 0.3f, 150, new Vector2(-1, 0), 0));
            this.Components.Add(new Bande(this, "Bande", new Vector2(0, 0), 1, 0, false));
            this.Components.Add(new Bande(this, "Bande", new Vector2(0, this._graphics.GraphicsDevice.Viewport.Height - 15f), 1, 0, false));
            this.Components.Add(new Paddle(this, "Paddle", new Vector2(20f, (this._graphics.GraphicsDevice.Viewport.Height / 2f) - 25), 1));
            this.Components.Add(new Bande(this, "Bande_hoch", new Vector2(0, 0), 1, 0, true));
            this.Components.Add(new Bande(this, "Bande_hoch", new Vector2(this._graphics.GraphicsDevice.Viewport.Width - 15f, 0), 1, 0, true));

            base.Initialize();
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            foreach (GameObject gameObject1 in this.Components)
            {
                if (gameObject1 is Ball)
                {
                    foreach (GameObject gameObject2 in this.Components)
                    {
                        if (((Ball)gameObject1).CheckKollision(gameObject2) && !gameObject1.Equals(gameObject2))
                        {
                            ((Ball)gameObject1).UpdateAfterKollision(gameObject2);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }

        #endregion
    }
}